

package jetbrains.buildServer.server.graphql.model.connections.agent;

import graphql.execution.DataFetcherResult;
import java.util.List;
import jetbrains.buildServer.server.graphql.model.AgentType;
import jetbrains.buildServer.server.graphql.model.connections.ExtensibleConnection;
import jetbrains.buildServer.server.graphql.model.connections.PaginatingConnection;
import jetbrains.buildServer.server.graphql.model.connections.PaginationArguments;
import jetbrains.buildServer.serverSide.agentTypes.SAgentType;
import org.jetbrains.annotations.NotNull;

public class AgentPoolAgentTypesConnection implements ExtensibleConnection<AgentType, AgentTypeEdge> {
  @NotNull
  private final PaginatingConnection<SAgentType, AgentType, AgentTypeEdge> myDelegate;

  public AgentPoolAgentTypesConnection(@NotNull List<SAgentType> data, @NotNull PaginationArguments paginationArguments) {
    myDelegate = new PaginatingConnection<>(data, AgentTypeEdge::new, paginationArguments);
  }

  @NotNull
  @Override
  public DataFetcherResult<List<AgentTypeEdge>> getEdges() {
    return myDelegate.getEdges();
  }

  public int getCount() {
    return myDelegate.getData().size();
  }
}